package com.example.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM user WHERE job_num = #{job_num}")
    User findByJobNum(@Param("job_num") Integer job_num);
    @Select("SELECT * FROM user WHERE uname = #{uname}")
    User findByUname(@Param("uname") String uname);
    @Select("SELECT * FROM user WHERE job_num = #{job_num} and phone = #{phone}")
    User findByJobNumAndPhone(@Param("job_num")Integer job_num, @Param("phone")String phone);

    @Select("SELECT * FROM user")
    List<User> findAllUsers();
    @Insert("INSERT INTO user(uname, upassword, phone, search, address, profession, job_num, items_count) " +
            "VALUES (#{uname}, #{upassword}, #{phone}, #{search}, #{address}, #{profession}, #{job_num}, #{items_count})")
    int insert(User user);

    @Update("UPDATE user SET upassword = #{upassword} WHERE job_num = #{job_num}")
    int updatePD(String upassword,Integer job_num);

    @Update("UPDATE user SET search = #{search} WHERE job_num = #{job_num}")
    int updateSearch(@Param("job_num")Integer job_num, @Param("search") Boolean search);
}